package com.bahiaapk;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

public class MainActivity extends TabActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    	setTabs() ;


    }
   
   private void setTabs(){
	  addTab("News", R.drawable.tab_news, NewsActivity.class);
	  addTab("Media", R.drawable.tab_media, MediaActivity.class);
      addTab("Jogos", R.drawable.tab_match, MatchActivity.class);
      addTab("Elenco", R.drawable.tab_cast, CastActivity.class);

   }
    	
   private void addTab(String labelId, int drawableId, Class<?> c){
    		TabHost tabHost = getTabHost();
    		Intent intent = new Intent(this, c);
    		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
    		
    		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
    		TextView title = (TextView) tabIndicator.findViewById(R.id.title);
    		title.setText(labelId);
    		ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
    		icon.setImageResource(drawableId);
    		
    		spec.setIndicator(tabIndicator);
    		spec.setContent(intent);
    		tabHost.addTab(spec);
    	}
    	
    }
